package leetcode;

import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;

/**
 * 描述:234. 回文链表
 *
 * @author Madison You
 * @created 2:26
 */
public class Easy_234_IsPalindrome {
    public static void main(String[] args) {

    }

    List<Integer> list = new ArrayList<>();

    public boolean isPalindrome(ListNode head) {
        while (head != null) {
            list.add(head.val);
            head = head.next;
        }

        int i = 0;
        int j = list.size() - 1;
        while (i < j) {
            if (list.get(i) == list.get(j)) {
                i++;
                j--;
            } else {
                return false;
            }
        }
        return true;
    }
}
